﻿using System;
using System.Windows.Input;

namespace LearnWPFDemo
{
    public class CommandBase : ICommand
    {
        public event EventHandler? CanExecuteChanged;

        public bool CanExecute(object? parameter)
        {
            return (DoCanExecute?.Invoke(parameter)).Value;
        }

        public void Execute(object? parameter)
        {
            DoAction?.Invoke(parameter);
        }

        public Action<Object> DoAction { get; set; }

        public Func<object, bool> DoCanExecute { get; set; }
    }
}
